package com.yanghx.order.server.util;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

/**
 * @author yangHX
 * createTime  2019/9/14 9:28
 */
public class JsonUtil {
    private static ObjectMapper objectMapper = new ObjectMapper();

    public static <T> T fromJson(String message, TypeReference<T> typeReference) {
        try {
            return objectMapper.readValue(message, typeReference);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
